<template>
    <div>
        <div id="slider" class="mui-slider">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll">
						<a :class="['mui-control-item',item.id==0?'mui-active':'']" v-for="item in subtitle":key="item.id" v-on:click="getImg(item.id)">
							{{item.title}}
						</a>
					</div>
				</div>
			</div>
	<ul class="colorcss">
  		<router-link tag=li  v-for="item in list" :key="item.id" :to="'/home/photosList/'+item.id">
    		<img v-lazy="item.img_url">
			<div class="info">
				<h5>{{item.title}}</h5>
				<span>{{item.zhaiyao}}</span>
			</div>
  		</router-link>
	</ul>
    </div>
	
</template>

<script>
import mui from '../../lib/mui/js/mui.min.js';
import {Toast} from 'mint-ui'
export default {
    data(){
        return {
			subtitle:"",
			list:[]
		}
    },
	mounted(){
		mui('.mui-scroll-wrapper').scroll({
		deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
		});
	},
	created(){
		this.getText();
		this.getImg(0)
	},
    methods:{
		getText(){
			this.$http.get("api/getimgcategory").then(result=>{
				if(result.body.status===0){
					result.body.message.unshift({title:"全部",id:0});
					this.subtitle = result.body.message
				}else{
					Toast("获取数据失败")
				}
				
			})
		},
		getImg(id){
			this.$http.get("api/getimages/"+id).then(result=>{
				if(result.body.status===0){
					this.list = result.body.message
					
				}else{
					Toast("获取图片信息失败")
				}
				
			})
		}
	}
}  
</script>

<style lang="">
*{
	touch-action:pan-y;
	list-style:none;
}
.colorcss{
	
	margin:0;
	padding:10px;
	text-align:center;
}
.colorcss li{
	margin-bottom:10px;
	box-shadow:0 0 8px #ccc;
	position:relative;
}
img{
	width:100%;
	display:block;
}
img[lazy=loading] {
  width: 40px;
  height: 300px;
  margin: auto;
  
}
.info{
	float:left;
	position:absolute;
	bottom:0;
}
.info h5{
	font-size:13px;
	color:#fff;
}
.info span{
	font-size:12px;
	color:#fff;
}
</style>